<?php
require('qs_connection.php');
require_once('gift_source_data_users.php');
require_once('qs_functions.php');
$err_string = "";
@session_start();
if (isset($_POST["act"])) {
    $emailrequest = qsrequest("email");
    $header_body   = "";
    $header_body .= " Header for body E-mail\n";
    $footer_body   = "";
    $footer_body .= " Footer for body E-mail\n";
    $msg_success   = "";
    $msg_success .= " <center>Successfully sent E-mail.</center>\n";
    $msg_success   .= "<br><br><a href=\"javascript:self.history.back();\">Go Back </a>";
    $str_emailfrom = "myemail@mydomainname.com";
    $str_subject = "Your Password Reminder Request.";
    $str_emailcc = "";
    $str_emailbcc = "";
    $str_replyto = "myemail@mydomainname.com";
    $email_priority = "3"; // 1 = High , 3 = Normal, 5 = Low
    $userlevel = 0;
    $ifound = 0;
    $emailrequest = qsrequest("email");
    $sql = "";
$sql .= "  SELECT `username` , `password` , `level` , `email` FROM `people`\n";
    $sql .= " WHERE ";
    $sql .= "username = '" . $emailrequest . "'";
    if(!$result = @mysql_query($sql)){
        $err_string .= "<strong>Error:</strong> while connecting to database<br>" . mysql_error();
    }else{
        $num_rows = mysql_num_rows($result);
        $row = mysql_fetch_array($result);
        $ifound = $num_rows;
    }
    if ($ifound > 0) {
        $str_body = "";
        $str_body = $str_body . $header_body . "\n\n" . "User name : " . $row[0] . "\n" . "Password : " . $row[1]  . "\n\n" . $footer_body;
        $str_emailto = $emailrequest;
        $header  = "";
        $header  = "From:".$str_emailfrom."\r\n";
        $header .= "Reply-to:".$str_replyto."\r\n";
        $header .= "Cc:".$str_emailcc ."\r\n";
        $header .= "Bcc:".$str_emailbcc ."\r\n";
        $header .= "X-Priority : ".$email_priority."\n";
        $success = @mail($str_emailto, $str_subject, $str_body, $header);
        if (!$success) {
            print "<br><br><font color=\"FF0000\"><center><center>Cannot send your E-mail.</center></center></font>";
        } else { //' Successfully send email
            print $msg_success;
        }
    } else {
            print "<br><br><font color=\"FF0000\"><center>Sorry, E-mail not found!</center></font>";
    }
}
?>
<HTML>
<HEAD>
<Title>Forgotten Password</Title>
<link rel="stylesheet" type="text/css" href="gift_source_data_password.css">
<meta http-equiv="Content-Type" content="text/html; utf-8">
<meta name="generator" content="dbQwikSite Ecommerce">
</HEAD>
<BODY><script language="javascript" src="./js/qs_menu.js"></script>
<CENTER>
<p align="left"><img style="left: 10px; top: 15px" alt="efd" hspace="0" src="http://www.evidencefordevelopment.com/templates/247extender_b/images/efd_100x65.png" align="baseline" border="0" /></p><CENTER>
<center><strong><font size="5">
</font></strong></center><br>

<A NAME=top></A>
<Form name="qs_password_form" method="post" action="./gift_source_data_password.php">
<Table Border="0" Cellpadding="2" Cellspacing="1" BgColor="#10783F">

<?php
$css_class = "\"TrOdd\"";
?>
<tr>
<td class="ThRows" align=Center>Your password will be sent to your account</td>
</tr>
<tr>
<td class="TrOdd"><input type="text" name="email"  size="40"></td>
</tr>
<tr>
<td class="TrOdd" align=Center>
<?php
#----get back url page----
  $backurl = "./gift_source_data.php?";
?>
<input type="button" name="QS_Back" value="Back" OnClick="javascript:window.location='<?php print $backurl; ?>'">&nbsp;&nbsp;
<input type="hidden" name="act" value="n">
<input type="submit" name="QS_Submit" value="Submit">&nbsp;&nbsp;
<input type="reset" name="Reset" value="Reset">
</td>
</tr>
</Table><br>
</Form>
<A NAME=bottom></A>
<div align="center"><a href="./project_setup.php" target="Back to Project Setup">Back to Project Setup</a></div>
</CENTER>

</BODY>
</HTML>
